package com.ybkj.takeout.shop.controller;

import com.ybkj.takeout.common.api.CommonResult;
import com.ybkj.takeout.common.model.EmptyIdListModel;
import com.ybkj.takeout.common.model.EmptyIdModel;
import com.ybkj.takeout.common.model.EmptyStringModel;
import com.ybkj.takeout.shop.model.activity.StartEndTimeModel;
import com.ybkj.takeout.shop.model.store.BusinessTrendVo;
import com.ybkj.takeout.shop.model.store.NoticeModel;
import com.ybkj.takeout.shop.model.store.ShopAdDataVo;
import com.ybkj.takeout.shop.model.store.ShopBussinessImagesVo;
import com.ybkj.takeout.shop.model.store.ShopCategoryAndIconUrlModel;
import com.ybkj.takeout.shop.model.store.ShopContactModel;
import com.ybkj.takeout.shop.model.store.ShopFoodTypeInsertModel;
import com.ybkj.takeout.shop.model.store.ShopFoodTypeUpdateModel;
import com.ybkj.takeout.shop.model.store.ShopNameModel;
import com.ybkj.takeout.shop.model.store.ShopOpenHoursModel;
import com.ybkj.takeout.shop.model.store.ShopSettingVo;
import com.ybkj.takeout.shop.model.store.TodayRealtimeDataVo;
import com.ybkj.takeout.shop.service.ShopShutdownProtectionService;
import com.ybkj.takeout.shop.service.StoreService;
import com.ybkj.takeout.sms.entity.ShopFoodType;
import com.ybkj.takeout.sms.entity.ShopShutdownProtection;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhyu
 * @date 2020/12/8 15:23
 */
@RestController
@Api(tags = "店铺模块")
@RequestMapping("/store")
@Slf4j
public class StoreController {

    @Autowired
    private StoreService storeService;
    @Autowired
    private ShopShutdownProtectionService shopShutdownProtectionService;

    @ApiOperation("添加商品分类")
    @PostMapping("addShopFoodType")
    public CommonResult<ShopFoodType> addShopFoodType(@Valid @RequestBody ShopFoodTypeInsertModel model){
        return CommonResult.success(storeService.addShopFoodType(model));
    }

    @ApiOperation("修改店铺商品分类")
    @PostMapping("updateShopFoodType")
    public CommonResult<ShopFoodType> updateShopFoodType(@Valid @RequestBody ShopFoodTypeUpdateModel model){
        return CommonResult.success(storeService.updateShopFoodType(model));
    }

    @ApiOperation(value = "获取单个店铺商品分类", notes = "接口data不为null")
    @GetMapping("getShopFoodType")
    public CommonResult<ShopFoodType> getShopFoodType(@RequestParam String id){
        return CommonResult.success(storeService.getShopFoodType(id));
    }

    @ApiOperation(value = "获取多个店铺商品分类", notes = "接口可能data不为null")
    @GetMapping("getShopFoodTypes")
    public CommonResult<List<ShopFoodType>> getShopFoodTypes(){
        return CommonResult.success(storeService.getShopFoodTypes());
    }

    @ApiOperation(value = "删除店铺商品分类")
    @PostMapping("deleteShopFoodType")
    public CommonResult<List<ShopFoodType>> deleteShopFoodType(@Valid @RequestBody EmptyIdModel model){
        storeService.deleteShopFoodType(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "修改商品分类排序")
    @PostMapping("updateSequence")
    public CommonResult<List<ShopFoodType>> updateSequence(@Valid @RequestBody EmptyIdListModel model){
        return CommonResult.success(storeService.updateSequence(model));
    }

    @ApiOperation(value = "获取店铺设置 app门店设置页面")
    @GetMapping("getStoreSetting")
    public CommonResult<ShopSettingVo> getStoreSetting(){
        return CommonResult.success(storeService.getStoreSetting());
    }

    @ApiOperation(value = "修改门店公告 门店设置->门店公告页面")
    @PostMapping("setAnnocePage")
    public CommonResult setAnnocePage(@RequestBody @Valid NoticeModel model){
        storeService.setAnnocePage(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "修改品类和店铺头像 门店设置->修改门店品类和头像")
    @PostMapping("setCategoryAndIconUrl")
    public CommonResult setCategoryAndIconUrl(@RequestBody @Valid ShopCategoryAndIconUrlModel model){
        storeService.setCategoryAndIconUrl(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "修改门店名称 门店设置->修改门店名称")
    @PostMapping("setShopName")
    public CommonResult setShopName(@RequestBody @Valid ShopNameModel model){
        storeService.setShopName(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "修改营业状态 门店设置->店铺营业状态页面")
    @PostMapping("setBusinessStatus")
    public CommonResult setBusinessStatus(@RequestBody @Valid EmptyStringModel model){
        storeService.setBusinessStatus(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "获取营业资质 门店设置->营业资质")
    @GetMapping("getBusinessImages")
    public CommonResult<ShopBussinessImagesVo> getBusinessImages(){
        return CommonResult.success(storeService.getBusinessImages());
    }

    @ApiOperation(value = "修改联系电话 门店设置->餐厅电话")
    @PostMapping("setContatNumber")
    public CommonResult setContatNumber(@RequestBody @Valid ShopContactModel model){
        storeService.setContatNumber(model);
        return CommonResult.success();
    }

    @ApiOperation(value = "设置营业时间 门店设置->营业时间")
    @PostMapping("setOpenhours")
    public CommonResult setOpenhours(@RequestBody @Valid ShopOpenHoursModel model){
        storeService.setOpenhours(model);
        return CommonResult.success();
    }

    @ApiOperation("获取歇业保护")
    @GetMapping("getShutdownProtection")
    public CommonResult<ShopShutdownProtection> getShutdownProtection() {
        return CommonResult.success(shopShutdownProtectionService.getShutdownProtection());
    }

    @ApiOperation("启动或者停止歇业保护")
    @PostMapping("stopOrStartupShutdownProtection")
    public CommonResult stopOrStartupShutdownProtection(@Valid @RequestBody EmptyStringModel model) {
        shopShutdownProtectionService.stopOrStartupShutdownProtection(model);
        return CommonResult.success();
    }

    @ApiOperation("获取经营数据营业趋势页面数据")
    @PostMapping("getBusinessTrendData")
    public CommonResult<BusinessTrendVo> getBusinessTrendData(@Valid @RequestBody StartEndTimeModel model) {
        return CommonResult.success(storeService.getBusinessTrendData(model));
    }

    @ApiOperation("获取今日实时数据页面数据")
    @GetMapping("getTodayRealtimeData")
    public CommonResult<TodayRealtimeDataVo> getTodayRealtimeData() {
        return CommonResult.success(storeService.getTodayRealtimeData());
    }

    @ApiOperation("获取门店推广页面数据")
    @GetMapping("getShopAdData")
    public CommonResult<ShopAdDataVo> getShopAdData() {
        return CommonResult.success(storeService.getShopAdData());
    }

    @ApiOperation("获取门店推广页面数据")
    @PostMapping("getShopAdData")
    public CommonResult<ShopAdDataVo> getShopAdData() {
        return CommonResult.success(storeService.getShopAdData());
    }

//    @ApiOperation(value = "获取营业资质  app门店设置页面->营业资质页面")
//    @GetMapping("getStoreSetting")
//    public CommonResult<> getStoreSetting(){
//        return CommonResult.success(storeService.getStoreSetting());
//    }
}
